Implement comprehensive authentication and authorization hardening#7
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Implement comprehensive authentication and authorization hardening#7devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
- Add JWT refresh token rotation and blacklisting mechanisms - Implement password strength requirements and history tracking - Enhance bcrypt configuration from salt 10 to 12 - Add account lockout after 5 failed attempts with progressive duration - Implement TOTP-based 2FA with backup codes and recovery - Add device/session management with max 5 concurrent sessions - Create security audit logging for all auth events - Add granular rate limiting for auth endpoints - Enhance password validation with complexity requirements Security enhancements include: - RefreshTokenService: token rotation, device fingerprinting, session limits - TwoFactorService: TOTP setup, QR codes, backup codes, recovery - AccountLockoutService: progressive lockout (5min, 15min, 1hr, 24hr) - PasswordHistoryService: prevent reuse of last 12 passwords - AuthSecurityService: centralized enhanced authentication logic - SecurityAuditLogEntity: comprehensive security event logging Database migrations added for new security tables: - refresh_tokens, password_history, user_two_factor - device_sessions, account_lockouts, security_audit_logs Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement comprehensive authentication and authorization hardening
Summary
This PR implements critical security enhancements for the banking application's authentication system, including JWT refresh token rotation, password security hardening, multi-factor authentication, and comprehensive audit logging.
Key Security Features Added:
New Database Tables:
refresh_tokens- Token management and device trackingpassword_history- Historical password hashesuser_two_factor- TOTP secrets and backup codesdevice_sessions- Active session trackingaccount_lockouts- Failed attempt trackingsecurity_audit_logs- Security event loggingReview & Testing Checklist for Human
Recommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TB AuthController["auth.controller.ts<br/>New 2FA & session endpoints"]:::major-edit AuthSecurityService["auth-security.service.ts<br/>Enhanced login logic"]:::major-edit TwoFactorService["two-factor.service.ts<br/>TOTP & backup codes"]:::major-edit RefreshTokenService["refresh-token.service.ts<br/>Token rotation"]:::major-edit AccountLockoutService["account-lockout.service.ts<br/>Progressive lockout"]:::major-edit Migration["1753786297884-SecurityEnhancements.ts<br/>New security tables"]:::major-edit UtilsService["utils.service.ts<br/>Enhanced password hashing"]:::minor-edit AuthModule["auth/index.ts<br/>New service registration"]:::minor-edit UserEntity["user.entity.ts<br/>Existing user data"]:::context AuthController --> AuthSecurityService AuthController --> TwoFactorService AuthController --> RefreshTokenService AuthSecurityService --> AccountLockoutService AuthSecurityService --> TwoFactorService AuthSecurityService --> RefreshTokenService TwoFactorService --> UserEntity RefreshTokenService --> UserEntity AccountLockoutService --> UserEntity Migration --> AuthModule UtilsService --> AuthSecurityService subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Security Dependencies Added:
speakeasyfor TOTP generationqrcodefor 2FA QR code generationargon2as backup password hashing optionBreaking Changes:
Link to Devin run: https://app.devin.ai/sessions/edb35af8f9474ce0a6949af00a9a3e19
Requested by: @akkp-windsurf